package com.ruoyi.system.controller;

import com.ruoyi.common.core.domain.CommonDto;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.api.domain.SysDictType;
import com.ruoyi.system.service.SysExcelservice;
import com.ruoyi.system.vo.req.AnalyExcelReqVO;
import com.ruoyi.system.vo.resp.AnalysisRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * @author xdh
 * @title SysExcelController
 * @date 2024/7/1 14:03
 * @description TODO
 */
@RestController
@RequestMapping("/excel")
@Api(tags = "数据导入相关接口")
public class SysExcelController {


    @Autowired
    private SysExcelservice sysExcelService;



    //@RequiresPermissions("system:file:analysis")
    @ApiOperation("上传文件并解析并返回业务unid")
    @PostMapping("/analysis")
    public R list(@RequestParam("file") MultipartFile file) throws IOException {
        return R.ok(sysExcelService.analysisExcel(file));
    }


    //@RequiresPermissions("system:file:page")
    @ApiOperation("上传文件后分页级异常信息")
    @PostMapping("/page")
    public R<AnalysisRespVO> page(@RequestBody AnalyExcelReqVO dto) {
        return R.ok(sysExcelService.page(dto));
    }


    //@RequiresPermissions("system:file:del")
    @ApiOperation("删除")
    @GetMapping("/del")
    public R page(Integer orderId) {
        return R.ok(sysExcelService.del(orderId));
    }

    //@RequiresPermissions("system:file:save")
    @ApiOperation("确认新增")
    @GetMapping("/save")
    public R page(Long  unid) {
        return R.ok(sysExcelService.save(unid));
    }


}
